package com.egao.common.publicly.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.egao.common.core.exception.ParameterException;
import com.egao.common.core.web.PageParam;
import com.egao.common.module.cms.entity.Question;
import com.egao.common.publicly.mapper.PubliclyQuestionMapper;
import com.egao.common.publicly.service.PubliclyQuestionService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 常见问题接口实现类
 * @author pyx
 */
@Service
public class PubliclyQuestionServiceImpl extends ServiceImpl<PubliclyQuestionMapper, Question> implements PubliclyQuestionService {

    @Override
    public List<Question> listPage(PageParam<Question> pageParam) {
        if(pageParam.getPageData().size() == 0){
            return new ArrayList<>();
        }
        pageParam.setSize(30);
        return baseMapper.listPage(pageParam);
    }

    @Override
    public Question getId(Integer id) {
        if (id == null) {
            throw new ParameterException("编号为空");
        }
        return baseMapper.selectById(id);
    }
}
